package com.alks.pad.service.serviceImpl.stitchAccount;


import com.alks.entity.data.response.ResponseInfo;
import com.alks.pad.commom.date.thread.PadUserIdThread;
import com.alks.pad.data.dto.padCollectUser.PadUserDeptDto;
import com.alks.pad.data.dto.stitch.EmployeeDto;
import com.alks.pad.data.request.stitchAccount.DeptRequest;
import com.alks.pad.mapper.stitchAccount.StitchDateMapper;
import com.alks.pad.service.stitchAccount.StitchDateService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
@Slf4j
public class StitchDateServiceImpl implements StitchDateService {

    @Autowired
    private StitchDateMapper stitchDateMapper;

    /**
     * 组别查询
     * @return
     */
    @Override
    public ResponseInfo getDeptNameList() {
        List<PadUserDeptDto> list = PadUserIdThread.get().getDepartmentList();

        HashMap map = new HashMap<>();
        PageInfo page = new PageInfo(list);
        map.put("total",page.getTotal());
        map.put("list",list);
        return ResponseInfo.ok(map);
    }

    /**
     * 员工查询
     * @return
     */
    @Override
    public ResponseInfo getEmployeelList(DeptRequest request) {
        String companyId = PadUserIdThread.get().getCompanyId();
        List<EmployeeDto> list = stitchDateMapper.getEmployeelList(companyId,request);

        HashMap map = new HashMap<>();
        PageInfo page = new PageInfo(list);
        map.put("total",page.getTotal());
        map.put("list",list);
        return ResponseInfo.ok(map);
    }

    /**
     * 所有组别查询
     * @param deptName
     * @return
     */
    @Override
    public ResponseInfo getAllDeptNameList(String deptName) {
        String companyId = PadUserIdThread.get().getCompanyId();
        List<PadUserDeptDto> list = stitchDateMapper.getAllDeptNameList(companyId,deptName);

        HashMap map = new HashMap<>();
        PageInfo page = new PageInfo(list);
        map.put("total",page.getTotal());
        map.put("list",list);
        return ResponseInfo.ok(map);
    }
}